package com.hss.rxjava.bean;

import com.hss.rxjava.CheckInterface;
import com.hss.rxjava.StringUtils;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public class OrderDetail implements CheckInterface {
	public String orderId;
	public String createTime;
	public String orderNo;
	public int orderStatus;
	public String orderPrice;
	public String addressedId;
	public String postFee;
	public String cashTotal;
	public String scoreNumTotal;
	public int refundType;//退款类型1.我要退款无需退货2：我要退货
	public int refundNum;//退款次数
	public String logisticsNo;//物流单号
	public String logisticsCompanyTitle;//物流公司
	public String agencyId;//供应商id
	public String agencyName;//供应商名称
	public String consignee;//收货人
	public String phoneno;//手机号
	public String detailAddress;//收货地址
	public String newAddress;//新收货地址
	public String eleNo;//电子单号
	public String zipCode;//地区
	public String backCallCash;//第三方支付额
	public String  buyerMessage;//买家留言
	public String  describe;//订单状态描述
	public int adsModifyState;// 1：被供应商修改过，0：未被供应商修改过,
	public int invoiceState;//发票状态：0为不开发票，1为开发票
	public int invoiceHead;// 发票抬头：0-个人，1-公司
	public String  invoiceHeadTitle;//抬头内容
	public int  invoiceContentId;
	public List<EleCouponsUseDetailDtoList> eleCouponsUseDetailDtoList;
	public LinkedList<OrderProduct> products;
	public String form;
	public String couponsType;
	public String couponsUrl;
	public Integer userdNo;
	public Integer totalNo;
	public String startTime;
	public String endTime;
	public String couponsCode;
	public String claimAmount;//理赔额
	public String payAmount;//第三方支付金额
	public String orderSerialNo;//医药云订单
	public String isPolicyPayment;//是否使用保单支付1:是，0:否

	public String getIsPolicyPayment() {
		return isPolicyPayment;
	}

	public void setIsPolicyPayment(String isPolicyPayment) {
		this.isPolicyPayment = isPolicyPayment;
	}

	public String getClaimAmount() {
		return claimAmount;
	}

	public void setClaimAmount(String claimAmount) {
		this.claimAmount = claimAmount;
	}

	public String getPayAmount() {
		return payAmount;
	}

	public void setPayAmount(String payAmount) {
		this.payAmount = payAmount;
	}

	public String getOrderSerialNo() {
		return orderSerialNo;
	}

	public void setOrderSerialNo(String orderSerialNo) {
		this.orderSerialNo = orderSerialNo;
	}

	public String getCouponsUrl() {
		return couponsUrl;
	}

	public void setCouponsUrl(String couponsUrl) {
		this.couponsUrl = couponsUrl;
	}

	public String getCouponsCode() {
		return couponsCode;
	}

	public void setCouponsCode(String couponsCode) {
		this.couponsCode = couponsCode;
	}

	public boolean checked = false;//我的订单-待付款列表中用

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public int getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(int orderStatus) {
		this.orderStatus = orderStatus;
	}

	public String getOrderPrice() {
		return orderPrice;
	}

	public void setOrderPrice(String orderPrice) {
		this.orderPrice = orderPrice;
	}

	public String getAddressedId() {
		return addressedId;
	}

	public void setAddressedId(String addressedId) {
		this.addressedId = addressedId;
	}

	public String getPostFee() {
		return postFee;
	}

	public void setPostFee(String postFee) {
		this.postFee = postFee;
	}

	public String getCashTotal() {
		return cashTotal;
	}

	public void setCashTotal(String cashTotal) {
		this.cashTotal = cashTotal;
	}

	public String getScoreNumTotal() {
		return scoreNumTotal;
	}

	public void setScoreNumTotal(String scoreNumTotal) {
		this.scoreNumTotal = scoreNumTotal;
	}

	public int getRefundType() {
		return refundType;
	}

	public void setRefundType(int refundType) {
		this.refundType = refundType;
	}

	public int getRefundNum() {
		return refundNum;
	}

	public void setRefundNum(int refundNum) {
		this.refundNum = refundNum;
	}

	public String getLogisticsNo() {
		return logisticsNo;
	}

	public void setLogisticsNo(String logisticsNo) {
		this.logisticsNo = logisticsNo;
	}

	public String getLogisticsCompanyTitle() {
		return logisticsCompanyTitle;
	}

	public void setLogisticsCompanyTitle(String logisticsCompanyTitle) {
		this.logisticsCompanyTitle = logisticsCompanyTitle;
	}

	public String getAgencyId() {
		return agencyId;
	}

	public void setAgencyId(String agencyId) {
		this.agencyId = agencyId;
	}

	public String getAgencyName() {
		return agencyName;
	}

	public void setAgencyName(String agencyName) {
		this.agencyName = agencyName;
	}

	public String getConsignee() {
		return consignee;
	}

	public void setConsignee(String consignee) {
		this.consignee = consignee;
	}

	public String getPhoneno() {
		return phoneno;
	}

	public void setPhoneno(String phoneno) {
		this.phoneno = phoneno;
	}

	public String getDetailAddress() {
		return detailAddress;
	}

	public void setDetailAddress(String detailAddress) {
		this.detailAddress = detailAddress;
	}

	public String getNewAddress() {
		return newAddress;
	}

	public void setNewAddress(String newAddress) {
		this.newAddress = newAddress;
	}

	public String getEleNo() {
		return eleNo;
	}

	public void setEleNo(String eleNo) {
		this.eleNo = eleNo;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getBackCallCash() {
		return backCallCash;
	}

	public void setBackCallCash(String backCallCash) {
		this.backCallCash = backCallCash;
	}

	public String getBuyerMessage() {
		return buyerMessage;
	}

	public void setBuyerMessage(String buyerMessage) {
		this.buyerMessage = buyerMessage;
	}

	public String getDescribe() {
		return describe;
	}

	public void setDescribe(String describe) {
		this.describe = describe;
	}

	public int getAdsModifyState() {
		return adsModifyState;
	}

	public void setAdsModifyState(int adsModifyState) {
		this.adsModifyState = adsModifyState;
	}

	public int getInvoiceState() {
		return invoiceState;
	}

	public void setInvoiceState(int invoiceState) {
		this.invoiceState = invoiceState;
	}

	public int getInvoiceHead() {
		return invoiceHead;
	}

	public void setInvoiceHead(int invoiceHead) {
		this.invoiceHead = invoiceHead;
	}

	public String getInvoiceHeadTitle() {
		return invoiceHeadTitle;
	}

	public void setInvoiceHeadTitle(String invoiceHeadTitle) {
		this.invoiceHeadTitle = invoiceHeadTitle;
	}

	public int getInvoiceContentId() {
		return invoiceContentId;
	}

	public void setInvoiceContentId(int invoiceContentId) {
		this.invoiceContentId = invoiceContentId;
	}

	public LinkedList<OrderProduct> getProducts() {
		return products;
	}

	public void setProducts(LinkedList<OrderProduct> products) {
		this.products = products;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public String getForm() {
		return form;
	}

	public void setForm(String form) {
		this.form = form;
	}

	public String getCouponsType() {
		return couponsType;
	}

	public void setCouponsType(String couponsType) {
		this.couponsType = couponsType;
	}

	public Integer getUserdNo() {
		return userdNo;
	}

	public void setUserdNo(Integer userdNo) {
		this.userdNo = userdNo;
	}

	public Integer getTotalNo() {
		return totalNo;
	}

	public void setTotalNo(Integer totalNo) {
		this.totalNo = totalNo;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public List<EleCouponsUseDetailDtoList> getEleCouponsUseDetailDtoList() {
		return eleCouponsUseDetailDtoList;
	}
	public void setEleCouponsUseDetailDtoList(List<EleCouponsUseDetailDtoList> eleCouponsUseDetailDtoList) {
		this.eleCouponsUseDetailDtoList = eleCouponsUseDetailDtoList;
	}


	public static class EleCouponsUseDetailDtoList implements Serializable {

		private String verifyTime;

		public String getVerifyTime() {
			return verifyTime;
		}

		public void setVerifyTime(String verifyTime) {
			this.verifyTime = verifyTime;
		}
	}

	@Override
	public boolean check(int index) {
		switch (index){
			case 1:
				if(!StringUtils.isNotNull(
						consignee,phoneno,zipCode,detailAddress,agencyName,products,createTime
				))return false;
				if(!StringUtils.isValidate(
						orderId,orderNo,orderPrice
				))return false;
				if(StringUtils.isValidate(logisticsCompanyTitle)
						&& !StringUtils.isNotNull(logisticsNo))return false;
				//为公司发票时抬头不能为null
				if(invoiceState == 1 && invoiceHead == 1 && invoiceHeadTitle == null)
					invoiceHeadTitle = "";
				break;
		}
		if(products != null){
			for(OrderProduct orderProduct : products){
				if(!orderProduct.check(index))return false;
			}
		}
		return true;
	}

	@Override
	public void fix(int index) {
		switch (index){
			case 1:
				consignee = StringUtils.makeStringNotNull(consignee);
				phoneno = StringUtils.makeStringNotNull(phoneno);
				zipCode = StringUtils.makeStringNotNull(zipCode);
				detailAddress = StringUtils.makeStringNotNull(detailAddress);
				agencyName = StringUtils.makeStringNotNull(agencyName);
				createTime = StringUtils.makeStringNotNull(createTime);
				break;
		}
		if(products != null){
			for(OrderProduct orderProduct : products){
				if(!orderProduct.check(index))orderProduct.fix(index);
			}
		}
	}
}
